<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:fn="http://java.sun.com/jsp/jstl/functions"
	xmlns:pe="http://primefaces.org/ui/extensions"
	template="/WEB-INF/template/defaultLayout.xhtml">

	<ui:define name="body">

		<h:form id="addProposal" enctype="multipart/form-data">
		
			<p:messages id="messagesAddPropositions" autoUpdate="true" closable="true" />
		
			<p:panelGrid id="AddProposalPanel" columns="2" columnClasses="allignedColumn">

				<h:outputLabel for="projectTitle" value="#{i18n.projectName}:" />
				<p:inputText maxlength="255" id="projectTitle"
					value="#{addProjectBB.newProject.title}" />

				<h:outputLabel for="description" value="#{i18n.description}:" />
				<p:inputTextarea rows="3" cols="30" maxlength="255" id="description"
					value="#{addProjectBB.newProject.description}" autoResize="false" />

				<h:outputText value="#{i18n.startDate}:" />
				<p:calendar id="startDate" value="#{addProjectBB.newProject.startDate}" >
					<p:ajax event="dateSelect" update="AddProposalPanel" />
				</p:calendar>

				<h:outputText value="#{i18n.endDate}:" />
				<p:calendar id="endDate" mindate="#{addProjectBB.newProject.startDate}" value="#{addProjectBB.newProject.endDate}" />

				<h:outputText value="#{i18n.price}:" />
				<p:inputText value="#{addProjectBB.newProject.price}" id="price">
					<pe:keyFilter for="price" mask="num" />
				</p:inputText>

				<h:outputLabel for="upload" value="#{i18n.documentation}:" />
				<p:fileUpload id="upload"
					fileUploadListener="#{addProjectBB.fileUpload}" mode="advanced"
					auto="true" label="UPLOAD" />
				
				<p:outputLabel for="daSelection" value="DA:" />
				<p:panelGrid id="daSelection" columns="1">
				
					<p:panelGrid columns="2" style="margin-bottom:10px" cellpadding="5">
				        <h:outputText value="Toti DA: " />
				        <p:selectBooleanCheckbox value="#{addProjectBB.projectPublic}">
				        	<p:ajax update="daSelection" />
				        </p:selectBooleanCheckbox>				       
			    	</p:panelGrid>
					
					<p:selectManyMenu id="advanced" value="#{addProjectBB.selectedUsers}" converter="#{userConverter}"
	                          var="user" filter="true" filterMatchMode="contains" showCheckbox="true" rendered="#{not addProjectBB.projectPublic}">
	            
		 	           	<f:selectItems value="#{addProjectBB.DAUsers}" var="users" itemLabel="#{users.firstName}" itemValue="#{users}" />
		 	            <p:column>
			                <p:outputLabel value="#{user.firstName}" />
			            </p:column>
	       		 	</p:selectManyMenu>
	       		 	
				</p:panelGrid>
		       
			</p:panelGrid>

			<p:commandButton action="#{addProjectBB.addProject}" value="#{i18n.save}" />
			
			<p:commandButton action="#{redirectMB.gotoCurrentProjects}" value="#{i18n.cancel}" immediate="true" />
			
		</h:form>
		
	</ui:define>
</ui:composition>